import { createRouter, createWebHashHistory } from 'vue-router';
import routes from './router.config.js';

export const router = createRouter({
    history: createWebHashHistory(), // createWebHistory => 不带#号,需后端支持  createWebHashHistory带#号
    routes
});

router.beforeEach((to, from,next) => {
    console.log(to);
    console.log(from);
    let Token = sessionStorage.getItem('tokenValue');
    if(!Token && to.name !== 'Login') {
        next({ name:'Login' })
    }else {
        next()
    }
})
